package thefirst.code.model;

import java.sql.SQLException;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import thefirst.common.PagingBean;
@Service
public class CodeServiceImpl implements CodeService {
	@Resource(name="codeDaoImpl")
	private CodeDao codeDao;
	@Override
	public List<CodeVO> findGenderByCode() throws SQLException {
		return codeDao.findGenderByCode();
	}
	@Override
	public int insertCode(CodeVO cvo) throws SQLException {
		return codeDao.insertCode(cvo);
	}
	@Override
	public int isExistCode(String code_code) throws SQLException {
		System.out.println("code service:"+code_code);
		return codeDao.isExistCode(code_code);
	}
	@Override
	public int updateCode(CodeVO cvo) throws SQLException {
		// TODO Auto-generated method stub
		return codeDao.updateCode(cvo);
	}
	@Override
	public void deleteCode(String code_no) throws SQLException {
		codeDao.deleteCode(code_no);
	}
	@Override
	public CodeListVO getTotalCodeList(String pageNo) throws SQLException {
		if(pageNo==null||pageNo==""){
			pageNo="1";
		}
		List<CodeVO> list=codeDao.getTotalCodeList(pageNo);
		int total=codeDao.getTotalCodeContent();
		System.out.println("code total"+total);
		PagingBean paging=new PagingBean(total, Integer.parseInt(pageNo));
		CodeListVO clvo=new CodeListVO(list,paging);
		return clvo;
	}
	@Override
	public CodeVO selectCodeInfo(int code_no) throws SQLException {
		return codeDao.selectCodeInfo(code_no);
	}

}
